package com.j.lemon.learn.basic.random;


import com.j.lemon.learn.basic.utils.SeqUtils;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.Future;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @Author lijunjun
 * @Date 2018-12-20 18:13
 * @Description
 */
public class ThreadTest {
    private static ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(8, 16,
            0L, TimeUnit.MILLISECONDS,
            new ArrayBlockingQueue<>(1024));


    public static void main(String[] args) {
        for(int i = 0 ;i<100;i++){
            Future<?> submit = threadPoolExecutor.submit(new TestThread());
            while(submit.isDone()){
                return;
            }
        }
    }

    private static class TestThread implements Runnable{

        @Override
        public void run() {
            System.out.println(SeqUtils.genSeqId());
            try {
                Thread.sleep(1500);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

        }
    }
}
